//
//  MainPageView.m
//  doubanFun
//
//  Created by bing on 16/4/1.
//  Copyright © 2016年 bing. All rights reserved.
//

#import "MainPageView.h"
#import "UIImage+Screen.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface MainPageView ()

@property (weak, nonatomic) IBOutlet UIImageView *backgroudView;
@property (weak, nonatomic) IBOutlet UIImageView *picture;
@property (weak, nonatomic) IBOutlet UILabel *songName;
@property (weak, nonatomic) IBOutlet UILabel *singerName;
@property (weak, nonatomic) IBOutlet UIView *toolView;
@property (nonatomic, strong) DFSong *song;

@end

@implementation MainPageView

- (void)awakeFromNib {
    [super awakeFromNib];
    _picture.layer.masksToBounds = YES;
    _picture.layer.cornerRadius = 100.f;
    _picture.contentMode = UIViewContentModeScaleAspectFill;
    _backgroudView.contentMode = UIViewContentModeScaleAspectFill;
}

- (void)setSongModal:(DFSong *)song {
    
    SDWebImageOptions option = SDWebImageRetryFailed;
    [self.picture sd_setImageWithURL:[NSURL URLWithString:song.picture] placeholderImage:[UIImage new] options:option
                           completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL)
     {
         if (error)
             NSLog(@"%@", error);
         else
         {
             self.picture.image = image;
             self.backgroudView.image = [image blurredImageWithRadius:10 iterations:1 tintColor:[UIColor whiteColor]];
         }
     }];
    
    _songName.text = song.title;
    
    _singerName.text = song.artist;
    
}


#pragma mark - action
// 歌词
- (IBAction)lyric:(id)sender {
    NSLog(@"%s",__FUNCTION__);
}

// 详情
- (IBAction)detail:(id)sender {
    NSLog(@"%s",__FUNCTION__);
}

// 分享
- (IBAction)shared:(id)sender {
    NSLog(@"%s",__FUNCTION__);
}
@end
